var router = require('express').Router()
var sql=require('../sql')
var Navcategory=require('../sql/models/Navcategory')
var Navlist=require('../sql/models/Navlist')

/**
 * @api {get} /api/nav/navcategory 获取导航分类
 * @apiName GetNavCategory
 * @apiGroup Nav
 *
 * @apiSuccess {String} code 状态码.
 * @apiSuccess {String} message  描述
 * @apiSuccess {String} data  数据
 *
 * @apiHeader {String} token token
 * 
 * @apiSuccessExample Success-Response:
 *     HTTP/1.1 200 OK
 *     {
 *       "code": "200",
 *       "message": "导航的分类数据",
 *       "data": []
 *     }
 * @apiSampleRequest /api/nav/navcategory
 */

router.get('/navcategory',(req,res,next)=>{
    sql.find(Navcategory,{},{_id:0,__v:0}).then(data=>{
        res.status('200').send({
            code: '200',
            message: '获取分类',
            data
          })
    })
    
})
/**
 * @api {get} /api/nav/navlist 获取导航列表
 * @apiName GetNavList
 * @apiGroup Nav
 *
 * @apiHeader {String} token token
 * @apiSuccess {String} code 状态码.
 * @apiSuccess {String} message  描述
 * @apiSuccess {String} data  数据
 *
 * 
 * @apiSuccessExample Success-Response:
 *     HTTP/1.1 200 OK
 *     {
 *       "code": "200",
 *       "message": "导航列表",
 *       "data": []
 *     }
 * @apiSampleRequest /api/nav/navlist
 */
router.get('/navlist', (req, res, next) => {
    sql.find(Navlist, {}, { _id: 0, __v: 0 }).then(data => {
      res.status('200').send({
        code: '200',
        message: '导航列表',
        data
      })
    })
  })

module.exports=router